﻿CREATE PROCEDURE [dbo].[AttachCategory]
@CategoryID INT, @ProjectID INT, @Duration INT
AS
IF EXISTS(SELECT * FROM ProjectCategories WHERE ProjectID = @ProjectID AND CategoryID = @CategoryID)
BEGIN
	UPDATE ProjectCategories 
	SET Duration = @Duration 
	WHERE ProjectID = @ProjectID 
			AND CategoryID = @CategoryID
END
ELSE
BEGIN
	INSERT INTO ProjectCategories
	(
		CategoryID,
		ProjectID,
		Duration
	)
	VALUES
	(
		@CategoryID,
		@ProjectID,
		@Duration
	)
END

